import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang

import zhLocale from '@/i18n/lang/zh.js'
import enLocale from '@/i18n/lang/en.js'

Vue.use(VueI18n)

const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh',
  messages: {
    en: {
      ...enLocale,
      ...elementEnLocale
    },
    zh: {
      ...zhLocale,
      ...elementZhLocale
    }
  }
})

export default i18n
